package com.xfunc.ok.dmok;

import okhttp3.RequestBody;
import okhttp3.ResponseBody;

public class ProgressHelper {
    /**
     * 包装请求体为带进度的请求体
     *
     * @param requestBody      待包装的请求体
     * @param progressListener 进度回调监听
     * @return 带进度的请求体，使用此请求体进行请求
     */
    static RequestBody withProgress(RequestBody requestBody, ProgressListener progressListener) {
        return new ProgressRequestBody(requestBody, progressListener);
    }

    /**
     * 包装请求体为带进度的响应体
     *
     * @param responseBody     待包装的响应体
     * @param progressListener 进度回调监听
     * @return 带进度的响应体，使用此响应体进行响应数据的读取
     */
    static ResponseBody withProgress(ResponseBody responseBody,  ProgressListener progressListener) {
        return new ProgressResponseBody(responseBody, progressListener);
    }
    static ResponseBody withProgress(String url, ResponseBody responseBody,ProgressListener progressListener) {
        return new ProgressResponseBody(responseBody, progressListener);
    }
}
